package com.audaque.springboot.foshanupload.core.handler;

import lombok.extern.slf4j.Slf4j;
import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler;

import java.lang.reflect.Method;

/**
 * @author zgb
 * @desc ...
 * @date 2023-08-25 15:49:39
 */
@Slf4j
public class AsyncUncaughtExceptionHandlerImpl implements AsyncUncaughtExceptionHandler {

    @Override
    public void handleUncaughtException(Throwable throwable, Method method, Object... objects) {
        log.error("异常捕获---------------------------------");
        log.error("ThreadConfig处理异步常异-->{},{}", method.getName(), objects, throwable);
        throwable.printStackTrace();
        log.error("Method name - " + method.getName());
        log.error("Exception message - " + throwable.getMessage());
        log.error("Exception string - " + throwable.toString());
        log.error("Exception stackTrace - " + throwable.getStackTrace());

        for (Object param : objects) {
            log.error("Parameter value - " + param);
        }
        log.error("异常捕获---------------------------------");

    }
}
